package at.ac.tuwien.swa.sparrow.peer.component

import akka.actor.ActorRef
import at.ac.tuwien.swa.sparrow.common.Ticket
import at.ac.tuwien.swa.sparrow.peer.PeerCommand.SongRecognition
import at.ac.tuwien.swa.sparrow.peer.PeerInterface
import at.ac.tuwien.swa.sparrow.server.PeerService
import com.typesafe.scalalogging.log4j.Logging
import javax.inject.Inject
import org.springframework.stereotype.Component
import scala.util.Success

@Component
class RequestHandler @Inject()(peerActor: ActorRef, peerService: PeerService, musicLibrary: MusicLibrary)
	extends PeerInterface with Logging {

	def request(ticket: Ticket) = {
		logger.info(s"Handling request of user ${ticket.userId}: ${ticket.id}")
		peerActor ! SongRecognition(ticket)
		Success(ticket)
	}

}
